const { ConfigProvider, message } = antd;
const { UseReqeustProvider, useRequest: useR } = ahooks;

function useRequest() {
    const args = [].slice.call(arguments);
    if (typeof args[1] === 'object') {
        args[1] = Object.assign(
            {},
            {
                manual: true,
            },
            args[1] || {}
        );
    } else {
        args[1] = {
            manual: true,
        };
    }
    return useR.apply(this, args);
}

var BASE_URL = '/';

var request = axios.create({
    base_URL: BASE_URL,
});

var required = (msg = '请输入该属性的值') => ({
    required: true,
    message: msg,
});

var typeMapping = {
    1: 'admin',
    2: 'teacher',
    3: 'student',
};

request.interceptors.response.use(
    function (response) {
        // 2xx 范围内的状态码都会触发该函数。
        // 对响应数据做点什么
        return response.data;
    },
    function (error) {
        // 超出 2xx 范围的状态码都会触发该函数。
        // 对响应错误做点什么
        message.error(error.message);
        return null;
    }
);

const AuthorityMap = {
    student: [],
    admin: [],
    teacher: [],
};

const sutdentRouteList = [
    {
        path: '/personCenter/',
        title: '个人中心',
    },
    {
        path: '/modifyPersonal/',
        title: '修改个人信息',
    },
    {
        path: '/modifyPassword/',
        title: '修改密码',
    },
    {
        path: '/classSchedule/',
        title: '课程表',
    },
];

const teacherRouteList = [
    {
        path: '/personCenter/',
        title: '个人中心',
    },
    {
        path: '/classSchedule/',
        title: '课程表',
    },
];

const adminRouteList = [
    {
        title: '课表',
        path: '/classSchedule',
        children: [
            {
                title: '添加课表',
                path: '/add',
            },
            {
                title: '修改课表',
                path: '/modify',
            },
            {
                title: '课表',
                path: '/list',
            },
        ],
    },
];

const routeMapping = {
    admin: adminRouteList,
    student: sutdentRouteList,
    teacher: teacherRouteList,
};

let routeList = [
    {
        path: '/list',
        title: '列表',
    },
    {
        path: '123',
        title: '123124',
        children: [
            {
                path: '123124',
                title: '123124',
            },
        ],
    },
];

ReactDOM.render(
    <ConfigProvider locale={zh_CN}>
        <App />
    </ConfigProvider>,
    document.getElementById('root')
);
